package com.subfg.common.rabbitmq.constant;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "用户自定义部分数据")
@JsonInclude(value=JsonInclude.Include.NON_NULL)
public class MQSubsetModel<T> implements Serializable {
    @ApiModelProperty(value = "唯一编号")
    private String id;
    @ApiModelProperty(value = "队列关联编号")
    private String mqId;
    @ApiModelProperty(value = "类型 [1: 支付  2: 退款 3: 提现]")
    private Integer type;
    @ApiModelProperty(value = "回调地址")
    private String webhook;
    @ApiModelProperty(value = "自定义附加信息")
    private T attach;
    @ApiModelProperty(value = "回调结果")
    private String callContent;
    @ApiModelProperty(value = "消费状态 [-1: 消费失败 0: 未开始消费 1: 消费成功]")
    private Integer status;
    @ApiModelProperty(value = "请求时间")
    private Long requestTime;
    @ApiModelProperty(value = "接收三方回调时间, 已本地接收回调为准")
    private Long callBackTime;

    @ApiModelProperty(value = "错误信息")
    private String exceptionInfo;
    @ApiModelProperty(value = "错误类名")
    private String exceptionName;


    public  static MQSubsetModel builderMqsub(String mqId, String webhook, Integer type, String attachJson, Long currentTime) {
        return new MQSubsetModel().builder()
                .mqId(mqId)
                .attach(attachJson)
                .requestTime(currentTime)
                .type(type)
                .webhook(webhook)
                .build();
    }

    public static MQSubsetModel clearExceptionInfo(MQSubsetModel mqSubsetModel) {
        mqSubsetModel.setExceptionInfo(null);
        mqSubsetModel.setExceptionName(null);
        mqSubsetModel.setCallContent(null);
        return mqSubsetModel;
    }
}
